package com.qf.qfuser.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.qf.qfcommons.pojo.R;
import com.qf.qfuser.feigns.OrderServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController5 {

    @Autowired
    private OrderServiceFeign orderServiceFeign;

    //利用Hystrix注解，标识这个方法为受保护资源
    @GetMapping("/{id}")
    public R findOrders(@PathVariable("id") Integer id) throws InterruptedException {

        //通过RestTemplate向Order服务发起请求，获取订单数据
        R r = orderServiceFeign.findByUid(id);
        return r;
    }

}
